import axios from 'axios';

axios.interceptors.request.use( config => {
    config.headers['Authorization'] = 'bearer '+ localStorage.getItem("token");
    return config;
});
axios.interceptors.response.use(
    response => {
        return response;
    },
    error => {
        if(error.response.status == 401){
            window.location = "/login";
        }
    return Promise.reject(error.response.data);
})





export {axios};
export const url = '/api'